package com.hut.oa.model.bean;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * 物品申请表
 * @author 熊涛
 *
 */
@Entity
@Table(name="apply_object")
public class ApplyObject {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="ao_id")	
	private Long id;//物品申请表id
	
	@Column(name="ao_type",nullable=false)
	private Integer type;//物品类型
	
	/*orphanRemoval = true 删除无关联数据*/
	@OneToMany(cascade=CascadeType.ALL,mappedBy="applyObject",orphanRemoval = true)
	private List<ApplyObjectList> applyObjectObject;//物品列表
	
	@JoinColumn(name="ao_apply_id",nullable=false)
	@OneToOne(cascade=CascadeType.ALL)
	private Apply apply;//通用申请

	public ApplyObject() {}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Apply getApply() {
		return apply;
	}

	public void setApply(Apply apply) {
		this.apply = apply;
	}
	

	public List<ApplyObjectList> getApplyObjectObject() {
		return applyObjectObject;
	}

	public void setApplyObjectObject(List<ApplyObjectList> applyObjectObject) {
		this.applyObjectObject = applyObjectObject;
	}

	@Override
	public String toString() {
		return "ApplyObject [id=" + id + ", type=" + type + "]";
	}
	
}
